﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyJsonSerialization
{
    class Person : IAssignable
    {
        #region IAssignable implementation
        
        public void AssignTo(object obj)
        {
            if (obj == null)
                throw new ArgumentNullException();

            if (obj is Person)
            {
                Person tempPers = obj as Person;

                tempPers.FName = this.FName;
                tempPers.LName = this.LName;
                tempPers.Age = this.Age;
                tempPers.Addresses = this.Addresses;

                return;
            }

            if (obj is JsonObject)
            {
                JsonObject tempJson = obj as JsonObject;
                JsonSerializer serializer = new JsonSerializer();
                tempJson.Result = serializer.Serialize(this).Result;
                return;
            }
            throw new NotSupportedException();
        }

        #endregion
        
        #region Properties

        public string FName { get; set; }
        public string LName { get; set; }
        public int Age { get; set; }
        public List<Address> Addresses { get; set; }

        #endregion
    }
}
